package cn.chenxiejia;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/***
 * @program: maven
 * @ClassName: Imges1
 * @Description:
 * @Author: chenxiejia
 * @Date: 2022/1/21 9:40
 * @version : V1.0
 */
public class Imges1 {
    public static void main(String[] args) throws IOException {
        //创建画板2为png,1为jpg
        BufferedImage i = new BufferedImage(500, 500, 2);
        //创建画笔
        var g = i.createGraphics();
        //设置画笔颜色
        g.setColor(Color.CYAN);
        //画线
        g.drawLine(0, 0, 50, 50);
        //关闭
        g.dispose();
        //画板写入文件
        ImageIO.write(i, "png", new File("i.png"));
        //调用系统命令运行图片
        Runtime.getRuntime().exec("cmd /k start i.png");
    }
}
